.NET Wrapper block
Architect and the Troubleshooters now allows users to create their own .NET objects that can then be wrapped inside one of the .NET Wrapper blocks to be used in running blueprints. There are four .NET Wrapper blocks in total in the Architect:
-
.NET Wrapper block (under Rules and Models)
-
.NET Wrapper Discrete Source block (under Historical IO)
-
.NET Wrapper Continuous Source block (under Historical IO)
-
.NET Wrapper Sink block (under Historical IO)
The .NET Wrapper blocks allow the user to integrate external .NET objects within the Architect environment. In this way, the user can add custom functionality, their own code, or third party libraries and objects to their solution.
There are three categories of .NET objects that can be created:
-
Normal objects that get input fields, manipulate the data according to the coded instructions, and then generate output fields.
-
Source objects that create output fields after manipulating data from an external source. These objects do not get any input fields. There are two types of source objects: continuous and discrete, depending on the process and therefore, the type of data recorded.
-
Sink objects that take input fields and manipulate the data, although do not generate output fields. Instead these input fields can be exported to external sources.
These objects can be written in any .NET language with the only requirement being that it supports .NET 2.0 or later.
NOTE: CSense provides secure native blocks and operations for building analytics and solutions. The native capabilities provided by CSense can be extended by making use of this feature. When making use of this feature, please ensure that you have validated your extended functions to ensure that they perform as intended and do not introduce stability or security risks to your production system. Do not use scripts or components from untrusted sources.
Description
External .NET objects that contain custom functionality (e.g., own code, libraries, or components) can be integrated within the Architect environment using the .NET Wrapper block. As Architect provides and manages runtime scheduling and interfacing, the third party .NET object only needs perform its own functionality. However, this object must also implement the IBlock Interface, enabling the integrated object to then interface and communicate with any other Architect block.
The IBlock Interface is therefore required by the .NET Wrapper block. This interface is used when your object takes input fields and generates output fields.
There are four types of interfaces, each corresponding with and required by the four types of .NET wrapper blocks. The four interfaces are:
-
IBlock: This interface is required by the .NET Wrapper block
-
IDiscreteSourceBlock: This interface is required by the Discrete .NET Wrapper Source block.
-
IContinuousSourceBlock: This interface is required by the Continuous .NET Wrapper Source block.
-
ISinkBlock: This interface is required by the .NET Wrapper Sink block.
NOTE: Both the IDiscreteSourceBlock and IContinuousSourceBlock derive from the ISourceBlock.
interface.
All four interfaces have almost the same method of operation, they just differ in parameters. All IBlock interfaces are defined in the .NETWrapperInterface.DLL assembly. This assembly also contains a group of enumerations, classes and interfaces that can be used by and passed to your object, through the interface.
The classes in the assembly are defined in the .NET Wrapper interface assembly.
These objects can be written in any .NET language with the only requirement that it supports .NET 2.0 or later. All objects are contained in .NET class library assembly files (DLL files) and need to be registered in Windows for clients to find them.
NOTE: One class library may contain multiple .NET objects.
.NET wrapper block
While in design-time, the .NET Wrapper’s operation is to:
-
Retrieve and configure the user control
-
Create all output fields the block will generate
-
Test runnability and return runnability result
While in runtime, the .NET Wrappers’s operation is to:
-
Notify the object that execution has started
-
Re-calculate the output values on every execution as the input values may have changed
-
Notify the object that execution has stopped and cleanup is necessary.
Block Type
Rules and Models: .NET Wrapper
Historical IO: .NET Wrapper Discrete Source, .NET Wrapper Continuous Source, and .NET Wrapper Sink
Input port
The Architect .NET Wrapper block has one input port that must contain input fields of the same type as the .NET objects input variables. The InputFields and InputValues containers are read-only containers. You cannot modify these containers.
Output port
When adding fields to the OutputFields container, remember the following:
-
All field names must be valid field identifiers. This can be checked with the IsValidIdentifier static method on the Field class. It takes a string and returns true if it is a valid identifier, otherwise false. You can also make a string a valid identifier with the MakeValidIdentifier static method on the Field class.
-
The OutputFields container must have fields with unique names. You may not add two fields with the same name to the container.
-
Use the IsNameAllowed method on the OutputFields to see if the field name is allowed into the container.
-
Use the IsTypeAllowed method on the OutputFields to see if the field type is allowed into the container.
The OutputValues container is a read-only container, but you may still change the timestamp, value and quality of the fields that is contained within the container. This OutputValues container will contain all the fields that you specified in the UpdateOutputFields method.
Functions performed on tags
The input values are sent through the .NET Wrapper block and the calculated output value(s) of the .NET object are placed in output fields of the .NET Wrapper block.
-
On the Quality, Value: If the quality or value of a field changes, the timestamp is changed. The new fields are user defined when configuring the output fields.
-
On the Timestamp: The timestamp may only increase. It may never be less than the last timestamp you set on that field.
Runnability
The minimum requirements for runnability on the .NET Wrapper block are:
-
a valid .NET DLL object file is loaded
-
a valid .NET object is selected
-
Object requires a connection to a valid source and a valid sink.
Terminology
-
.NET: The .NET framework is a large library of pre-coded solutions to common programming problems and manages the execution of programs written specifically for the framework.
-
.NET object: an component create within the .NET Framework
Related topics: